for i in range(int(1e7), 1, -1):
    # 只需要取后两位数
    # i= 197
    fib = []
    n = i
    while n:
        fib.append(n % 10)
        n //= 10
    fib.reverse()
    length = len(fib)
    if i % 1000 == 0: print("Running", i)

    while fib[-1] < i:
        r = 0
        for j in range(1, length + 1):
            r += fib[-j]
        fib.append(r)
    if fib[-1] == i:
        print(i)
        break
